﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace BanVeXemPhim_Presentation
{
    public class KhachHangDAO:DataProvider
    {
        public void ThemKhachHang(KhachHangDTO khachHangDto)
        {
            connect();
            string query = "insert into khachhang(hoten,cmnd,diachi) values('" + khachHangDto.HoTen + "','" + khachHangDto.CMND + "','" + khachHangDto.DiaChi + "')";
            command = connection.CreateCommand();
            command.CommandText = query;
            command.ExecuteNonQuery();
        }

        public int  LayIdKhachHang(KhachHangDTO khachHangDto)
        {
            connect();
            string query = "select IdKhachHang from KhachHang where Hoten='"+khachHangDto.HoTen+"' and CMND='"+khachHangDto.CMND+"' and DiaChi='"+khachHangDto.DiaChi+"'";
            command = connection.CreateCommand();
            command.CommandText = query;
            object o = command.ExecuteScalar();
            if (o != null)
            {
                int result = (int)o;
                return result;
            }
            return -1;
        }
    }
}
